package src;

public class MyThread extends Thread
{
    String myname;

    public MyThread(String name)
    {
        this.myname = name;
    }

    /*
     * run dos run
     * 
     * @see java.lang.Thread#run()
     */
    public void run()
    {
        int taid = 0;
        int pageid_dummy = 0;
        try
        {
            pageid_dummy = 10 * Integer.parseInt(myname);
        }
        catch (Exception E)
        {
            // es war keine Zahl
        }
        taid = persistenzManager.getInstance().beginTransaction();
        System.out.println("Client " + myname + " bekommt Transaktionsnr " + taid);

        for (int i = 0; i < 10; i++)
        {

            persistenzManager.getInstance().write(taid, pageid_dummy + i, "Daten" + String.valueOf(pageid_dummy + i));
            try
            {
                Thread.sleep(pageid_dummy * 10);
            }
            catch (InterruptedException e)
            {
                return;
            }
        }
        persistenzManager.getInstance().commit(taid);
    }
}